package com.znsd.zl.dict.controller;

import com.znsd.zl.dict.entity.DictEntity;
import com.znsd.zl.dict.service.IDictService;
import com.znsd.zl.utils.BaseController;
import com.znsd.zl.utils.PageUtils;
import com.znsd.zl.utils.R;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * @ClassName DictController
 * @Description TODO
 * @Author zhubin
 * @Date 2020/8/17 19:52
 * @Version v1.0
 */
@RestController
@RequestMapping("zl/dict")
public class DictController extends BaseController<IDictService, DictEntity,Integer> {


	@RequestMapping("/list")
	public R list(@RequestParam Map<String, Object> params){
		PageUtils page = service.queryPage(params);
		return R.ok().put("page",page);
	}


	@Override
	@PostMapping
	public R save(@RequestBody DictEntity dictEntity) {
		boolean save = service.save(dictEntity);
		String msg = save ? "操作成功" : "不能添加重复类型";
		return save ? R.ok().put("msg",msg) : R.error().put("msg",msg);
	}


}
